﻿
var pageDetail = new Sail.page({
    name     : "pagedetail",                 //定义页面对象的唯一标识 名称
    haveNavi : false,
      
    frames   : {
        name     : "frameMain",            //该frame对象的唯一标识
        title    : "进货单",                 //标题文本
        getURL : "../../purchase.do?method=edit",
        postURL : "../../purchase.do?method=save",
        getUrlParameter : ["id"],
        //-------------------------------------------------------------------------------
        //以JSON形式描述 frame 的构成(包含哪些 item)
        //-------------------------------------------------------------------------------
        items    : [
            {
                name  : "formDetail",
                type  : "form", 
                title : "进货单新增",
                buttons : ["保存","关闭"],
                
               "items"    : [
                  {   
                      type:"calendar",    
                      title:"进货日期",  
                      allowBlank : false,    
                      dataIndex:"dataset.billVo.billDate" 
                  },
                  {   
                      type:"input",
                      title:"单据编号",
                      allowBlank : false,
                      dataIndex:"dataset.billVo.billCode"
                  },
                  {   
                      type:"input",
                      title:"单据类型",
                      allowBlank : false,
                      dataIndex:"dataset.billVo.billTypeId"
                  },
                  {   
                      type:"input",
                      title:"填报人",
                      allowBlank : false,
                      dataIndex:"dataset.billVo.operator"
                  },
                  {   
                      type:"input",    
                      title:"备注",     
                      allowBlank : true,
                      dataIndex:"dataset.billVo.remark"
                  }
    	         ],
                 "layoutConfig" : {
					        columns : 2
					    		},
    "layout" : [
        {                   
            items:[
                {'name':'进货日期'},{'name':'单据编号'}
              
            ]
        },
       
        {
            items:[
               
                {'name':'单据类型'}, {'name':'填报人'}
            ]
        },{
            items:[
              
                {'name':'备注',colspan:2 }
            ]
        }
    ]
            },
            {
                name      : "gridson",
                type      : "editGrid",
                title     : "进货单明细",
                bbar      : false,
                allowBlank : false,
                 haveCheckCol: false,
                 tbar : [],
                tbar      : ['新增','-','删除'],
                bindRelation   : {
                    root : "dataset.billVo.billDetail",
                    id    : "id",
                    col   :[
                       {   "header":"产品名称",  		"align":"right","dataIndex":"materielId",  "width":100 },
                       {   "header":"数量",   "align":"right","dataIndex":"amount",  "width":100 }
                    ],
                    editor : [
                             {type:"textField",config:{allowBlank:false}},
              							 {type:"numberField",config:{decimalPrecision:4,minvalue:0,allowBlank:false}}
                       ]
                    
                }
            }
        ],
        businessData : {

        },

        bindEvent2Items : function(){  
             var frame = this;
             var obj_form =  $('formDetail');
             
             obj_form.getButton('关闭').on('click',function(){
                this.close();
             },frame);
             
             var obj_grid = $("gridson");
             
            
             
             obj_form.getButton('保存').on('click',function()
              {
                $('formDetail').ownerFrame.saveBusiness("close");
             },frame);
        }   
    }
    //进入页面自动加载数据
	
  
});

pageDetail.run();